# 1、行政区域查询
def geo_aa_search(key, keywords):
    # 高德地图API行政区域查询
    url_geo1 = "https://restapi.amap.com/v3/config/district?parameters"
    params_geo1 = {
        "key": key,
        "keywords": keywords
    }
    response = requests.get(url=url_geo1, params=params_geo1)
    # 返回值
    return response.json()


# 2、搜索POI
def geo_POI_search(key, keywords, types):
    # 高德地图POI查询
    url_geo2 = "https://restapi.amap.com/v3/place/text?parameters"
    params_geo2 = {
        "key": key,
        "keywords": keywords,
        "types": types
    }
    response = requests.get(url=url_geo2, params=params_geo2)
    # 返回值
    return response.json()


# 3、IP定位
def geo_IP_location(key):
    # 高德地图IP定位
    url_geo3 = "https://restapi.amap.com/v3/ip?parameters"
    params_geo3 = {"key": key}
    response = requests.get(url=url_geo3, params=params_geo3)
    # 返回值
    return response.json()


# 4、批量请求接口

# 5、静态地图
def geo_map(key, location, zoom):
    # 高德地图获取目的地的静态地图
    # zoom范围从1~17
    url_geo5 = "https://restapi.amap.com/v3/staticmap?parameters"
    params_geo5 = {
        "key": key,
        'location': location,
        'zoom': zoom,
    }
    response = requests.get(url=url_geo5, params=params_geo5)
    # 返回一条链接，在浏览器中打开便可得到目的地的静态地图
    return response.url


# 6、坐标转换
def geo_location_translate(key, locations, coordsys):
    # 高德地图转换输入的坐标 coordsys不填则不运行
    url_geo6 = "https://restapi.amap.com/v3/assistant/coordinate/convert?parameters"
    params_geo6 = {
        "key": key,
        "locations": locations,
        "coordsys": coordsys
    }
    response = requests.get(url=url_geo6, params=params_geo6)
    # 返回值
    return response.json()


# 7、天气查询
def geo_weather_search(key, city):
    # 道德地图的查询天气
    # city填的地区编码 如广东省是440000
    url_geo7 = "https://restapi.amap.com/v3/weather/weatherInfo?parameters"
    params_geo7 = {
        "key": key,
        "city": city
    }
    response = requests.get(url=url_geo7, params=params_geo7)
    # 返回值
    return response.json()


# 8、输入提示
def geo_tips(key, keywords, city):
    # 高德地图查找东西的提示
    # city填城市编码 如广州市是020
    url_geo8 = "https://restapi.amap.com/v3/assistant/inputtips?parameters"
    params_geo8 = {
        "key": key,
        "keywords": keywords,
        "city": city
    }
    response = requests.get(url=url_geo8, params=params_geo8)
    # 返回值
    return response.json()


# 9、交通态势
def traffic_info(key, rectangle):
    # 高德地图获得交通态势
    # 无法使用
    url_geo9 = "https://restapi.amap.com/v3/traffic/status/rectangle?parameters"
    params_geo9 = {
        "key": key,
        "rectangle": rectangle
    }
    response = requests.get(url=url_geo9, params=params_geo9)
    # 返回值
    return response.json()
